/*
 * 
 */



package com.itwill.ecom.boardQnA;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
@Repository("boardQnADao")
public class BoardQnADaoImpl implements BoardQnADao {
	
	private final static String namespace="com.itwill.ecom.boardQnA.BoardQnAMapper";
	@Autowired
	private SqlSession session;
	
	public SqlSession getSession() {
		return session;
	}
	public void setSession(SqlSession session) {
		this.session = session;
		System.out.println("BoardQnADaoImpl 생성입니다.");
	}
	
	
	/********** 생성 ***********/
	@Override
	public int createBoardQnA(BoardQnABeans boardQnABeans) {
		
		return session.insert(namespace+".create_qnaboard", boardQnABeans);
	}
	
	
	/********** 리스트호출 **********/
	@Override
	public List<BoardQnABeans> getAllBoardQnA() {
	
		return session.selectList(namespace+".list_qnaboard");
	}
	
	
	/********** 내 게시물 검색 **********/
	@Override
	public List<BoardQnABeans> getById(String qnaboard_id) {
		return session.selectList(namespace+".my_qnaboard",qnaboard_id);
	}
	
	
	/********** 내 게시물 수정 **********/
	@Override
	public int updateBoardQnA(BoardQnABeans boardQnABeans) {
		return session.insert(namespace+".update_qnaboard", boardQnABeans);
	}
	
	
	/********** 내 게시물 삭제 **********/
	@Override
	public int deleteBoardQnA(int qnaboard_no) {
		return session.delete(namespace+".delete_qnaboard",qnaboard_no);
	}
	/********** No로 게시글 검색 **********/
	@Override
	public BoardQnABeans getByNo(int qnaboard_no) {
		
		return session.selectOne(namespace+".detail_qnaboard",qnaboard_no);
	}
	
	

}
